<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}" />
    <title>layout 后台大布局 - Layui</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">layui 后台登陆布局</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
    </div>
    <div class="layui-body">
        <!-- 内容主体区域 -->
        <form class="layui-form layui-form-pane">
            <table>
                <div class="form-group">
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户</label>
                        <div class="layui-input-inline">
                            <input name="sale_user" id="sale_user" class="layui-input" type="text" placeholder="请输入" autocomplete="off" lay-verify="required">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">密码</label>
                        <div class="layui-input-inline">
                            <input name="sale_pwd" id="sale_pwd" class="layui-input" type="password" placeholder="请输入" autocomplete="off" lay-verify="required">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">所属物业</label>

                            <div class="layui-input-inline">
                            <select name="sale_property_id" id="sale_property_id">
                                <option value="">请选择</option>
                                @foreach($data as $v)
                                    <option value="{{$v->property_id}}">{{$v->property_name}}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">验证手机</label>
                            <div class="layui-input-inline">
                                <input type="hidden" id="_token" name="_token" value="{{ csrf_token() }}">
                                <input type="tel" name="sale_tel" id="sale_tel" lay-verify="required|phone" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-input-block">
                    <button  class="layui-btn" lay-submit id="tweets_sub"  lay-filter="tweets_sub">提交</button>
                    <button type="reset" class="layui-btn-primary layui-btn">重置</button>
                </div>
            </table>
        </form>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © layui.com - 底部固定区域
    </div>
</div>
<script src="/layui/layui.js"></script>
<script src="/js/jq.js"></script>

<script>
    layui.use('form', function(){
        var form = layui.form;
        form.on('submit(tweets_sub)', function(){
            var sale_user = $('#sale_user').val();
            var sale_pwd = $('#sale_pwd').val();
            var sale_property_id = $('#sale_property_id').val();
            var sale_tel = $('#sale_tel').val();
            var _token = $('#_token').val();
            var data = new FormData();
            data.append('sale_user',sale_user);
            data.append('sale_pwd',sale_pwd);
            data.append('sale_property_id',sale_property_id);
            data.append('sale_tel',sale_tel);
            data.append('_token',_token);
            $.ajax({
                type:"post",
                url:"{{url('/admin/register_res')}}",
                data:data,
                cache: false,
                processData: false,
                contentType: false,
                success:function(msg){
                    if(msg==1){
                        window.location.href = 'http://www.cucurbit.com/admin/login';//登录成功跳转
                    }else{
                        alert('添加No');
                        parent.location.reload();
                    }
                },
            });
            return false;
        });
    });
</script>

</body>
</html>